<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>首页</title>
	<meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
	<script src="js/vue/vue.js"></script>
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/homePage.css">
	<link rel="stylesheet" href="css/flexible.css">
	<link rel="stylesheet" href="css/vant.css">
	<script src="js/jquery-3.3.1.min.js"></script>
	<script src="js/flexible.js"></script>
	<script src="js/vue/axios.js"></script>
	<script src="js/vue/qs.js"></script>
	<script src="js/vue/MD5.js"></script>
	<script src="js/vue/vant.js"></script>
</head>
<body>
<div id="app">
	<template>
		<ul class="course_header">
			<li>
				<p><span>{{dataList.curr_t_num}}</span><span class="fontsize12">&nbsp;节</span></p>
				<p>本月已上团课</p>
			</li>
			<li>
				<p><span>{{dataList.curr_p_num}}</span><span class="fontsize12">&nbsp;节</span></p>
				<p>本月已上私课</p>
			</li>
		</ul>
		<div class="container_box">
			<div class="day_course">
				<span>
					今日课程
				</span>
				<!-- <span>
					<a href="#">我的课表</a>
				</span> -->
			</div>
		</div>
		<div class="tar_qh">
			<ul class="nav">
				<li v-for="(item,index) in dataKc" @click="tar(index)">
				<span :class="{selected:currindex==index}">{{item.name}} <span>
					{{item.curr_day_num_t}} 节</span></span>
				</li>
			</ul>
			<div class="content">
				<div class="list" v-if="currindex=='0'">
					<div v-if="curr_list.curr_t.length>0">
						<div class="clearfix border1" v-for="items in curr_list.curr_t">
							<div class="fl cousre_time">
								<img src="images/time.png"/>
								<p class="fontsize12">{{items.Stime}}</p>
							</div>
							<div class="spinning_txt fl">
								<p>
									<span class="spinning_txx">{{items.Title}}</span>
									<span class="spinning_name">{{dataList.Sname}}</span></p>
								<p>
									<span class="spinning_A">{{items.Space}}</span>
									<span class="spinning_date">{{items.Stime}}-{{items.Etime}}</span>
								</p>
								<p class="degree">{{items.Besnum ? items.Besnum:0}}/{{items.Max}} <span class="many_full">预约满{{items.Min}}人开课</span></p>
							</div>
							<div class="appoint_ment fr" @click="seeYyList(items.id)">查看</div>
						</div>
					</div>
					<div v-else style="margin-top: .2rem;text-align: center;">
						<img src="images/notDate.jpg"/>
					</div>
				</div>
				<div class="list" v-else>
					<div v-if="curr_list.curr_p.length>0">
						<div v-for="items in curr_list.curr_p">
							<div class="clearfix border1">
								<div class="fl private_course">
									<img class="private_img" src="images/time.png"/>
									<p class="fontsize12">{{items.Stime}}</p>
								</div>
								<div class="spinning_txt fl width70">
									<div class="private_message">
										<p>
											<span class="spinning_txx">{{items.Title}}</span>
											<span class="spinning_name">{{dataList.Sname}}</span>
										</p>
										<p>
											<span class="spinning_A" style="font-size: .12rem;background: #fff;">{{items.Sname[0].Username}}</span>
											<span class="spinning_date">{{items.Stime}}-{{items.Etime}}</span>
										</p>
									</div>
								</div>
							</div>
							<div class="clearfix border1" v-for="itemss in items.Ulist">
								<div class="fl private_course">
									<img class="private_imgs" :src="itemss.Picurl" onerror="this.src='images/moren.png'"/>
								</div>
								<div class="spinning_txt fl width70">
									<div class="fl">
										<div class="fl">
											<p>
												<span class="spinning_txx">{{itemss.Username}}</span>
												<span class="spinning_name">{{itemss.Phone}}</span>
											</p>
											<p class="clearfix">
												<span class="spinning_A" style="font-size: .12rem;background: #fff;">{{itemss.Cardname}}</span>
												<span class="spinning_A" style="font-size: .12rem;background: #fff;">剩余{{itemss.Surplus}} {{itemss.Surplus_C}}</span>
											</p>
											<p class="degree">预约时间<span class="many_full">{{itemss.Besdate}}</span></p>
										</div>
										<div v-if="itemss.IsReserve=='0'" @click="pSignIn(itemss.id,itemss.Currid)" class="private_Sign fr" >签到</div>
										<div v-if="itemss.IsReserve=='0'" @click="pCancel(itemss.id,itemss.Currid)" class="private_Sign private_Sign1 fr">取消预约</div>
										<div v-else-if="itemss.IsReserve=='1'" style="margin-left: .1rem;" class="private_Sign private_Sign1 fr">已签到</div>
										<div v-else class="private_Sign private_Sign1 fr" style="margin-left: .1rem;">已取消</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div v-else style="margin-top: .2rem;text-align: center;">
						<img src="images/notDate.jpg"/>
					</div>
				</div>
			</div>
		</div>
	</template>
	<div class="footer_bar">
		<ul class="clearfix">
			<li>
				<a href="index.html" class="first_a foot_active">
					<p style="color: #333346;">首页</p>
				</a>
			</li>
			<li>
				<a href="league.html" class="second_a">
					<p>代约团课</p>
				</a>
			</li>
			<li>
				<a href="privateLessons.html" class="thrid_a">
					<p>代约私教</p>
				</a>
			</li>
			<li>
				<a href="myMember.html" class="four_a">
					<p>我的会员</p>
				</a>
			</li>
		</ul>
	</div>
</div>
</body>




<script>
var app = new Vue({
	el: '#app',
	data: {
		vid:'',
		titles:'',
		dataList:{
			curr_t_num:'0',
			curr_p_num:'0',
			Sname:''
		},
		dataKc:[
			{
				name:'团课',
				curr_day_num_t:'0'
			},
			{
				name:'私教',
				curr_day_num_t:'0'
			},
		],
		currindex:'0',
		curr_list:{
			curr_t:[]
		}
	},
	created(){
		this.setCanS()
	},
	methods: {
			//设置参数
			setCanS(){
				let Request = new Object()
				Request = GetRequest()
				this.vid = Request['vid']
				//获取场馆名称
				if(this.vid==undefined||this.vid==''||this.vid==null){
					this.vid=''
				}else{
					sessionStorage.setItem('vid',this.vid)
				}
				this.getList()
			},
			getList(){
				sessionStorage.setItem('logo','0')
				getVs()
				axios.get('/mobileapi/coach/index.php').then(data => {
					console.log(data.data)
					let { msg, code} = data.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							var data = data.data.data
							this.dataList.curr_t_num=data.curr_t_num
							this.dataList.curr_p_num=data.curr_p_num
							this.dataList.Sname=data.Sname
							this.dataKc[0].curr_day_num_t=data.curr_day_num_t
							this.dataKc[1].curr_day_num_t=data.curr_day_num_p
							this.curr_list=data.curr_list
						}
					}).catch(function (error) { 
						console.log(error); 
				})
			},
			//切换课程
			tar(index){
				this.currindex=index
			},
			//私教的签到
			pSignIn(id,currid){
				const params={
					id:id,
					currid:currid
				}
				getVs()
				axios.get('/mobileapi/coach/sign.php?act=sign',{params:params}).then(data => {
					console.log(data.data)
					let { msg, code} = data.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							window.vant.Toast.success("签到成功")
							this.getList()
						}
					}).catch(function (error) { 
						console.log(error); 
				})
			},
			//私教的取消预约
			pCancel(id,currid){
				const params={
					id:id,
					currid:currid
				}
				getVs()
				axios.get('/mobileapi/coach/sign.php?act=sign_pass',{params:params}).then(data => {
					console.log(data.data)
					let { msg, code} = data.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							window.vant.Toast.success("取消成功")
							this.getList()
						}
					}).catch(function (error) { 
						console.log(error); 
				})
			},
			//跳转到团课的签到和取消预约列表
			seeYyList(Besid){
				window.location.href='yyList.html?besid='+Besid+''
			}
		}  
})
</script>
</html>